﻿/********************************************************************************/
// <copyright file="EventFactory.cs" company="Asia E-Business Solutions">
//     Copyright © 2012. All right reserved
// </copyright>
// <history>
//     <change who="Phuoc Le" date="24/12/2012 3:00:36 PM">Created</change>
// </history>
/********************************************************************************/

using System;
using System.Collections.Generic;
using JLL.China.Infrastructure.Repositories.Admin;
using LINQ = JLL.China.Infrastructure.Repositories.LINQ2SQL;

namespace JLL.China.Infrastructure.Repositories.Event
{
    public static class EventFactory
    {
        public static Model.Event FromLINQObject(LINQ.Event _event)
        {
            if (_event == null)
                return null;
            else
            {
                var model = new Model.Event
                {
                    ID = _event.ID,
                    Event_ID = _event.Event_ID,
                    Title = _event.Title,
                    EventType = _event.EventType,
                    EventSummary = _event.EventSummary,
                    EventContent = _event.EventContent,
                    EventDate = _event.EventDate,
                    EventDateEnd = _event.EventDateEnd,
                    EventTime = _event.EventTime,
                    EventTimeEnd = _event.EventTimeEnd,
                    //Venue = _event.Venue,
                    EventColor = _event.EventColor,
                    Where = _event.Where,
                    Status = _event.Status,
                    LanguageFID = (decimal) (_event.LanguageFID),
                    ContactEmail = _event.ContactEmail,
                    DateCreated  = _event.DateCreated,
                    CreatedBy = _event.CreatedBy,
                    Admin = AdminFactory.FromLINQObject(_event.Admin),
                    DateUpdated =  _event.DateUpdated
                };
                return model;
            }
        }

        public static LINQ.Event ToLINQObject(Model.Event _event)
        {
            var model = new LINQ.Event
            {
                ID = _event.ID,
                Event_ID = _event.Event_ID,
                Title = _event.Title,
                EventType = _event.EventType,
                EventSummary = _event.EventSummary,
                EventContent = _event.EventContent,
                EventDate = _event.EventDate,
                EventDateEnd = _event.EventDateEnd,
                EventTime = _event.EventTime,
                EventTimeEnd = _event.EventTimeEnd,
               // Venue = _event.Venue,
                EventColor = _event.EventColor,
                Where = _event.Where,
                LanguageFID = (decimal)(_event.LanguageFID),
                Status = _event.Status,
                ContactEmail = _event.ContactEmail,
                DateCreated = _event.DateCreated,
                CreatedBy = _event.CreatedBy,
                AdminFID = _event.Admin.ID,
                DateUpdated =  _event.DateUpdated
            };
            return model;
        }
    }
}
